package com.fulong.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.fulong.entity.DeviceOrgInfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.fulong.service.DeviceOrgInfoService;
import com.fulong.common.utils.PageUtils;
import com.fulong.common.utils.R;



/**
 * 
 *
 * @author fanknag
 * @email ${email}
 * @date 2022-04-18 21:02:33
 */
@RestController
@RequestMapping("/deviceorginfo")
public class DeviceOrgInfoController {
    @Autowired
    private DeviceOrgInfoService deviceOrgInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestBody Map<String, Object> params){
        PageUtils page = deviceOrgInfoService.queryPage(params);

        return R.ok().put("page", page);
    }

    @RequestMapping("/orgtree")
    public R treeList(){
        List<DeviceOrgInfoEntity> list = deviceOrgInfoService.withTree();
        return R.ok().put("list" , list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		DeviceOrgInfoEntity deviceOrgInfo = deviceOrgInfoService.getById(id);

        return R.ok().put("deviceOrgInfo", deviceOrgInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DeviceOrgInfoEntity deviceOrgInfo){
		deviceOrgInfoService.save(deviceOrgInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DeviceOrgInfoEntity deviceOrgInfo){
		deviceOrgInfoService.updateById(deviceOrgInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
		deviceOrgInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
